import pygame, sys
from pygame.locals import *
from player import *
from cenario import *

pygame.init() 
clock = pygame.time.Clock()
screen = pygame.display.set_mode((798,672))



player = Player(84,126)
fase = Cenario('ponte')
background = fase.imagem_de_fundo
lista_de_players = [player]

while True:
	clock.tick(80)
	key = pygame.key.get_pressed()
	for event in pygame.event.get():
		if event.type == QUIT or player.vidas == 0:
			pygame.quit()
			sys.exit()
		if event.type == KEYUP:
			if key[pygame.K_RETURN] and player.status == 'VIVO':
				player.soltar_boma(fase)
	if player.status == 'VIVO':
		if key[pygame.K_LEFT]:
			player.muda_sprite('ESQUERDA')
			player.move(-player.velocidade, 0)
			fase.colisao_de_movimento(-player.velocidade, 0, player)
		if key[pygame.K_RIGHT]:
			player.muda_sprite('DIREITA')
			player.move(player.velocidade, 0)
			fase.colisao_de_movimento(player.velocidade, 0, player)
		if key[pygame.K_UP]:
			player.muda_sprite('CIMA')
			player.move(0, -player.velocidade)
			fase.colisao_de_movimento(0, -player.velocidade, player)
		if key[pygame.K_DOWN]:
			player.muda_sprite('BAIXO')
			player.move(0, player.velocidade)
			fase.colisao_de_movimento(0, player.velocidade, player)

	screen.blit(background,(0,0))
	fase.desenha_itens(screen,lista_de_players)
	fase.colisao_estatica(player)
	screen.blit(player.player_imagem,(player.rect.x-4,player.rect.y-29))
	pygame.display.update()
